<?php
namespace app\wxapp\controller;

class Audit extends Base{


	public function __construct(){
		parent::__construct();
	}

	/**
     * 审核信息 提交保存
     * @return [type] [description]
     */
    public function getlist(){
        $post = input('post.');

        if( !isset($post['user_id']) ||  !isset($post['tabIndex']) ||  !isset($post['pagesize']) ||  !isset($post['pageno']) ){
			$this->res['code'] = '888';
			$this->res['msg'] = '缺少参数';
			die(myJSON($this->res));
        }

        $model = model('useseal');
        $map= array();
        $map['b.user_id'] = $post['user_id'];


        if( $post['tabIndex'] == 0 ){
        	$map['b.status'] = 0;
        }
        // $map['status'] = ['>',-2];

        $list = model('useseal')->alias('a')
                    ->field( 'a.* , b.status as b_status ,b.step as b_step ')
                    ->join('bc_useseal_audit b', ' b.id = a.id' )
                    ->where($map)
                    ->order( 'a.id desc , step asc ' )
                    ->page( $post['pageno'] , $post['pagesize'])
                    ->select();
// $this->res['sql'] = db()->getLastSql();

        foreach($list as $k => $v){
        	$v->status_text = $v->status_text ;
        	$v->user;
        	$v->equipment;
        	$v->seal;
        }

        if( !$list ){
            $this->res['code'] = '999';
			$this->res['msg'] = '没有数据了';
			die(myJSON($this->res));
        }else{

        	$this->res['data'] = $list; 
			die(myJSON($this->res));

        };

    }
}